<template>
  <div class="home">
    <h1>{{ $store.state.msg }}</h1>
    <h1>{{ $store.state.num }}</h1>
    <button @click="changenum">让vuex里的数据++</button>
    <child />
  </div>
</template>

<script>
import child from "../components/Child.vue";
export default {
  components: {
    child,
  },
  methods: {
    changenum() {
      this.$store.commit("change", 5);
      //因为methods没有权利修改state，所以只能调用一个mutation去修改state
      // commit方法就是用来调用mutation
    },
  },
};
</script>
